package Gui;

import Database.AccountDB;
import Database.AccountDetailsDB;
import Database.AdminDB;
import Database.BranchDB;
import Database.DurationDB;
import Database.DurationDetailsDB;
import Database.LoanTypeDB;
import Database.RoleDB;
import Entity.Account;
import Entity.AccountDetails;
import Entity.Admin;
import Entity.Branch;
import Entity.Duration;
import Entity.DurationDetails;
import Entity.LoanType;
import Entity.Role;
import Entity.SystemTimer;
import Entity.TestRenderer;
import Manager.LoanTypeManager;
import Manager.Manager;
import Model.AccountDetailsModel;
import Model.AccountTableModel;
import Model.AdminTableModel;
import Model.BranchTableModel;
import Model.CustomerDurationsTableModel;
import Model.DurationDetailsTableModel;
import Model.DurationTableModel;
import Model.LoanRegisterTableModel;
import Model.LoanTypeTableModel;
import Model.RoleTableModel;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.RowSorter;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author CONG
 */
public final class SystemManager extends javax.swing.JFrame {

    /** Creates new form SystemManager */
    private Manager manager;
    private Account acc;
    private AccountTableModel modelAccount;
    private AccountDB dbAccount;
    private AdminTableModel modelAdmin;
    private AdminDB dbAdmin;
    private BranchTableModel modelBranch;
    private BranchDB dbBranch;
    private LoanTypeTableModel modelLoanType;
    private LoanTypeDB dbLoanType;
    private DurationTableModel modelDuration;
    private DurationDB dbDuration;
    private AccountDetailsModel modelAccountDetails;
    private AccountDetailsDB dbAccountDetails;
    private CustomerDurationsTableModel modelCustomerDurations;
    private DurationDetailsTableModel modelDurationDetails;
    private DurationDetailsDB dbDurationDetails;
    private RoleTableModel modelRole;
    private RoleDB dbRole;
    private int flag = 0;
    private Admin ad = null;
    private LoanRegisterTableModel modelLoanRegister;
    private DialogLogin dialogLogin;
    private ArrayList<Admin> listAd;
    private ArrayList<Role> listRole;
    private ArrayList<LoanType> listLoanType;
    private ArrayList<Duration> listDuration;
    private ArrayList<AccountDetails> listAccde;
    private ArrayList<Account> listAcc;

    public SystemManager() {
        initComponents();
        this.setLocationRelativeTo(null);
        URL url = getClass().getResource("/Image/icon.png");
        Image img = Toolkit.getDefaultToolkit().getImage(url);
        this.setIconImage(img);
        SystemTimer timer = new SystemTimer(this);
        timer.start();

        acc = new Account();
        dbAdmin = new AdminDB();
        this.setVisible(true);

        dialogLogin = new DialogLogin(this, true, manager, dbAdmin);
        dialogLogin.setVisible(true);
        ad = dialogLogin.getAdmin();
        manager = new Manager();
        /* Show Account in database*/
        dbAccount = new AccountDB();
        modelAccount = new AccountTableModel(manager);
        /*Show Admins in database */

        modelAdmin = new AdminTableModel(manager);
        listAd = dbAdmin.getAdminList();
        /* Show Branch in Database */
        modelBranch = new BranchTableModel(manager);
        dbBranch = new BranchDB();
        modelBranch.getBranchList(dbBranch.getBranchList());
        tblBranch.setModel(modelBranch);

        /* Show LoanType in database*/
        modelLoanType = new LoanTypeTableModel(manager);
        dbLoanType = new LoanTypeDB();
        modelLoanType.getLoanTypeList(dbLoanType.getLoanTypeList());
        tblLoanType.setModel(modelLoanType);

        /*Show Duration in database */
        modelDuration = new DurationTableModel(manager, dbAccount);
        dbDuration = new DurationDB();
//        modelDuration.getDurationList(dbDuration.getDurationList());
//        tblListDuration.setModel(modelDuration);

        /*Get Data account details in database */
        dbAccountDetails = new AccountDetailsDB();
        modelAccountDetails = new AccountDetailsModel(manager);
        modelAccountDetails.getAccountDetailsList(dbAccountDetails.getAccopuntDetailsList());

        /* Get data role in database */
        dbRole = new RoleDB();
        modelRole = new RoleTableModel(manager);
        modelRole.getRolesList(dbRole.getRolesList());

        dbDurationDetails = new DurationDetailsDB();
        modelDurationDetails = new DurationDetailsTableModel(manager);
        if (ad != null) {
            checkLogin(ad);
        }
        modelLoanRegister = new LoanRegisterTableModel(manager);
        tblLoanRegister.setModel(modelLoanRegister);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpanelMain = new javax.swing.JTabbedPane();
        pnlManager = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblManager = new javax.swing.JTable();
        jPanel10 = new javax.swing.JPanel();
        btnAdd = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lblAccount = new javax.swing.JLabel();
        lblFullName = new javax.swing.JLabel();
        lblAddress = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        lblPhone = new javax.swing.JLabel();
        lblPermission = new javax.swing.JLabel();
        pnlBranch = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblBranch = new javax.swing.JTable();
        jPanel14 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        txtAddress = new javax.swing.JTextField();
        txtPhone = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        btnNew = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        btnRemove = new javax.swing.JButton();
        chkStatus = new javax.swing.JCheckBox();
        pnlRegister = new javax.swing.JPanel();
        jPanel21 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblLoanRegister = new javax.swing.JTable();
        jPanel23 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        chkAccept = new javax.swing.JCheckBox();
        chkNotAccept = new javax.swing.JCheckBox();
        lblIdRegister = new javax.swing.JLabel();
        lblNameRegister = new javax.swing.JLabel();
        lblDOBRegister = new javax.swing.JLabel();
        lblAddressRegister = new javax.swing.JLabel();
        lblPhoneRegister = new javax.swing.JLabel();
        lblEmailRegister = new javax.swing.JLabel();
        lblOrgRegister = new javax.swing.JLabel();
        lblLoanAmountRegister = new javax.swing.JLabel();
        lblLoanTypeRegister = new javax.swing.JLabel();
        lblPeriodRegister = new javax.swing.JLabel();
        lblBranchRegister = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        pnlCustomer = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        txtSearch = new javax.swing.JTextField();
        cbbChoice = new javax.swing.JComboBox();
        btnOk = new javax.swing.JButton();
        jPanel18 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblCustomer = new javax.swing.JTable();
        btnCustomerReport = new javax.swing.JButton();
        btnDeleteDuration = new javax.swing.JButton();
        jPanel19 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        lblCusAddress = new javax.swing.JLabel();
        lblCusName = new javax.swing.JLabel();
        lblCusBirthday = new javax.swing.JLabel();
        lblCusPhone = new javax.swing.JLabel();
        lblCusEmail = new javax.swing.JLabel();
        lblCusOrg = new javax.swing.JLabel();
        lblCusSalary = new javax.swing.JLabel();
        jPanel20 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tblCusDuration = new javax.swing.JTable();
        btnCusDurationDetails = new javax.swing.JButton();
        pnlDuration = new javax.swing.JPanel();
        jPanel24 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tblListDuration = new javax.swing.JTable();
        jPanel25 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        tblListDurationHistory = new javax.swing.JTable();
        btnFinish = new javax.swing.JButton();
        pnlLoanType = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jPanel16 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtLoanTypes = new javax.swing.JTextField();
        txtDescription = new javax.swing.JTextField();
        txtRate = new javax.swing.JTextField();
        btnNewLoanType = new javax.swing.JButton();
        btnEditLoanType = new javax.swing.JButton();
        btnSaveLoanType = new javax.swing.JButton();
        btnDeleteLoanType = new javax.swing.JButton();
        chkStatusLoanType = new javax.swing.JCheckBox();
        jPanel17 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblLoanType = new javax.swing.JTable();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        mnLoanRegister = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        mnEditProfile = new javax.swing.JMenu();
        mnEditManager = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Loan Management System");

        jpanelMain.setFont(new java.awt.Font("Tahoma", 0, 15));
        jpanelMain.setMinimumSize(new java.awt.Dimension(105, 150));
        jpanelMain.setPreferredSize(new java.awt.Dimension(100, 500));

        pnlManager.setEnabled(false);

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Manager List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        tblManager.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblManager.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblManagerMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblManager);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel10.setPreferredSize(new java.awt.Dimension(745, 64));

        btnAdd.setFont(new java.awt.Font("Tahoma", 1, 12));
        btnAdd.setForeground(new java.awt.Color(44, 44, 44));
        btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/add-16x16.png"))); // NOI18N
        btnAdd.setText("Add new manager");
        btnAdd.setEnabled(false);
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });
        jPanel10.add(btnAdd);

        btnDelete.setFont(new java.awt.Font("Tahoma", 1, 12));
        btnDelete.setForeground(new java.awt.Color(44, 44, 44));
        btnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/delete-16x16.png"))); // NOI18N
        btnDelete.setText("Delete manager");
        btnDelete.setEnabled(false);
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });
        jPanel10.add(btnDelete);

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Manager Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setForeground(new java.awt.Color(33, 33, 33));
        jLabel1.setText("Account:");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setForeground(new java.awt.Color(33, 33, 33));
        jLabel2.setText("Fullname:");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel3.setForeground(new java.awt.Color(44, 44, 44));
        jLabel3.setText("Permission:");

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setForeground(new java.awt.Color(44, 44, 44));
        jLabel4.setText("Email:");

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setForeground(new java.awt.Color(44, 44, 44));
        jLabel5.setText("Phone:");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setForeground(new java.awt.Color(33, 33, 33));
        jLabel6.setText("Adddress:");

        lblAccount.setFont(new java.awt.Font("Arial", 1, 12));
        lblAccount.setForeground(new java.awt.Color(76, 76, 76));
        lblAccount.setPreferredSize(new java.awt.Dimension(40, 17));

        lblFullName.setFont(new java.awt.Font("Arial", 1, 12));
        lblFullName.setForeground(new java.awt.Color(76, 76, 76));
        lblFullName.setPreferredSize(new java.awt.Dimension(40, 17));

        lblAddress.setFont(new java.awt.Font("Arial", 1, 12));
        lblAddress.setForeground(new java.awt.Color(76, 76, 76));
        lblAddress.setPreferredSize(new java.awt.Dimension(40, 17));

        lblEmail.setFont(new java.awt.Font("Arial", 1, 12));
        lblEmail.setForeground(new java.awt.Color(76, 76, 76));
        lblEmail.setPreferredSize(new java.awt.Dimension(40, 17));

        lblPhone.setFont(new java.awt.Font("Arial", 1, 12));
        lblPhone.setForeground(new java.awt.Color(76, 76, 76));
        lblPhone.setPreferredSize(new java.awt.Dimension(40, 17));

        lblPermission.setFont(new java.awt.Font("Arial", 1, 12));
        lblPermission.setForeground(new java.awt.Color(76, 76, 76));
        lblPermission.setPreferredSize(new java.awt.Dimension(40, 17));

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(lblAccount, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblFullName, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(53, 53, 53)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPermission, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap(89, Short.MAX_VALUE)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel4)
                    .addComponent(lblAccount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel5)
                    .addComponent(lblFullName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel6)
                    .addComponent(lblAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPermission, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(43, 43, 43))
        );

        javax.swing.GroupLayout pnlManagerLayout = new javax.swing.GroupLayout(pnlManager);
        pnlManager.setLayout(pnlManagerLayout);
        pnlManagerLayout.setHorizontalGroup(
            pnlManagerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlManagerLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlManagerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, 782, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlManagerLayout.setVerticalGroup(
            pnlManagerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlManagerLayout.createSequentialGroup()
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jpanelMain.addTab("Manage Manager", pnlManager);

        pnlBranch.setEnabled(false);

        jPanel12.setPreferredSize(new java.awt.Dimension(765, 64));

        jLabel7.setFont(new java.awt.Font("Arial", 1, 24));
        jLabel7.setForeground(new java.awt.Color(102, 102, 255));
        jLabel7.setText("Manage Branches");
        jPanel12.add(jLabel7);

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Branches List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N
        jPanel13.setLayout(new java.awt.BorderLayout());

        tblBranch.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblBranch.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblBranchMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblBranch);

        jPanel13.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Branch Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel8.setForeground(new java.awt.Color(44, 44, 44));
        jLabel8.setText("Name:");

        jLabel9.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel9.setForeground(new java.awt.Color(44, 44, 44));
        jLabel9.setText("Address:");

        jLabel10.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel10.setForeground(new java.awt.Color(44, 44, 44));
        jLabel10.setText("Phone:");

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel11.setForeground(new java.awt.Color(44, 44, 44));
        jLabel11.setText("Email: ");

        txtName.setPreferredSize(new java.awt.Dimension(6, 22));

        txtAddress.setPreferredSize(new java.awt.Dimension(6, 22));

        txtPhone.setPreferredSize(new java.awt.Dimension(6, 22));
        txtPhone.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPhoneKeyTyped(evt);
            }
        });

        txtEmail.setPreferredSize(new java.awt.Dimension(6, 22));

        btnNew.setFont(new java.awt.Font("Arial", 1, 12));
        btnNew.setForeground(new java.awt.Color(44, 44, 44));
        btnNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/add-16x16.png"))); // NOI18N
        btnNew.setText("New");
        btnNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewActionPerformed(evt);
            }
        });

        btnEdit.setFont(new java.awt.Font("Arial", 1, 12));
        btnEdit.setForeground(new java.awt.Color(44, 44, 44));
        btnEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Edit-16x16.png"))); // NOI18N
        btnEdit.setText("Edit");
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });

        btnSave.setFont(new java.awt.Font("Arial", 1, 12));
        btnSave.setForeground(new java.awt.Color(44, 44, 44));
        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/save-16x16.png"))); // NOI18N
        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnRemove.setFont(new java.awt.Font("Arial", 1, 12));
        btnRemove.setForeground(new java.awt.Color(44, 44, 44));
        btnRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/delete-16x16.png"))); // NOI18N
        btnRemove.setText("Delete");
        btnRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveActionPerformed(evt);
            }
        });

        chkStatus.setFont(new java.awt.Font("Arial", 1, 12));
        chkStatus.setForeground(new java.awt.Color(44, 44, 44));
        chkStatus.setSelected(true);
        chkStatus.setText("Status");

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnNew)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEdit)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRemove))
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(chkStatus)
                            .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(12, 12, 12))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(14, 14, 14)
                .addComponent(chkStatus)
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSave)
                    .addComponent(btnEdit)
                    .addComponent(btnNew)
                    .addComponent(btnRemove))
                .addContainerGap(88, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlBranchLayout = new javax.swing.GroupLayout(pnlBranch);
        pnlBranch.setLayout(pnlBranchLayout);
        pnlBranchLayout.setHorizontalGroup(
            pnlBranchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE)
            .addGroup(pnlBranchLayout.createSequentialGroup()
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, 370, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, 374, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(52, Short.MAX_VALUE))
        );
        pnlBranchLayout.setVerticalGroup(
            pnlBranchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBranchLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(pnlBranchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBranchLayout.createSequentialGroup()
                        .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
                        .addContainerGap(72, Short.MAX_VALUE))
                    .addGroup(pnlBranchLayout.createSequentialGroup()
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );

        jpanelMain.addTab("Manage Branch", pnlBranch);

        pnlRegister.setEnabled(false);

        jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Loan Register List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        tblLoanRegister.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblLoanRegister.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblLoanRegisterMouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(tblLoanRegister);

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel23.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Loan Register Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        jLabel25.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel25.setForeground(new java.awt.Color(44, 44, 44));
        jLabel25.setText("ID:");

        jLabel26.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel26.setForeground(new java.awt.Color(44, 44, 44));
        jLabel26.setText("Full Name:");

        jLabel27.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel27.setForeground(new java.awt.Color(44, 44, 44));
        jLabel27.setText("Date of Birth:");

        jLabel28.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel28.setForeground(new java.awt.Color(44, 44, 44));
        jLabel28.setText("Address:");

        jLabel29.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel29.setForeground(new java.awt.Color(44, 44, 44));
        jLabel29.setText("Phone:");

        jLabel30.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel30.setForeground(new java.awt.Color(44, 44, 44));
        jLabel30.setText("Email:");

        jLabel31.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel31.setForeground(new java.awt.Color(44, 44, 44));
        jLabel31.setText("Organization:");

        jLabel32.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel32.setForeground(new java.awt.Color(44, 44, 44));
        jLabel32.setText("Loan Amount:");

        jLabel33.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel33.setForeground(new java.awt.Color(44, 44, 44));
        jLabel33.setText("Loan Type:");

        jLabel34.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel34.setForeground(new java.awt.Color(44, 44, 44));
        jLabel34.setText("Period Year:");

        jLabel35.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel35.setForeground(new java.awt.Color(44, 44, 44));
        jLabel35.setText("Branch:");

        chkAccept.setFont(new java.awt.Font("Arial", 1, 12));
        chkAccept.setForeground(new java.awt.Color(44, 44, 44));
        chkAccept.setText("Accept");
        chkAccept.setEnabled(false);

        chkNotAccept.setFont(new java.awt.Font("Arial", 1, 12));
        chkNotAccept.setForeground(new java.awt.Color(44, 44, 44));
        chkNotAccept.setText("Not Accept");
        chkNotAccept.setEnabled(false);

        lblIdRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblIdRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblIdRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblNameRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblNameRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblNameRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblDOBRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblDOBRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblDOBRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblAddressRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblAddressRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblAddressRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblPhoneRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblPhoneRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblPhoneRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblEmailRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblEmailRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblEmailRegister.setText("jLabel36");
        lblEmailRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblOrgRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblOrgRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblOrgRegister.setText("jLabel36");
        lblOrgRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblLoanAmountRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblLoanAmountRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblLoanAmountRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblLoanTypeRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblLoanTypeRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblLoanTypeRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblPeriodRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblPeriodRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblPeriodRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        lblBranchRegister.setFont(new java.awt.Font("Arial", 1, 12));
        lblBranchRegister.setForeground(new java.awt.Color(76, 76, 76));
        lblBranchRegister.setPreferredSize(new java.awt.Dimension(40, 17));

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel30)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jLabel31)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblOrgRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel25)
                            .addComponent(jLabel26)
                            .addComponent(jLabel27)
                            .addComponent(jLabel28)
                            .addComponent(jLabel29))
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblIdRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblNameRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblAddressRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblDOBRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblPhoneRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblEmailRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(77, 77, 77)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addComponent(chkAccept)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(chkNotAccept))
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel32)
                                    .addComponent(jLabel33)
                                    .addComponent(jLabel34)
                                    .addComponent(jLabel35))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblBranchRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblLoanTypeRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblLoanAmountRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblPeriodRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(90, Short.MAX_VALUE))
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(jLabel32)
                    .addComponent(lblIdRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblLoanAmountRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(jLabel33)
                    .addComponent(lblNameRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblLoanTypeRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(jLabel34)
                    .addComponent(lblDOBRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPeriodRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(jLabel35)
                    .addComponent(lblAddressRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblBranchRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel29)
                            .addComponent(lblPhoneRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel30)
                            .addComponent(lblEmailRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel31)
                            .addComponent(lblOrgRegister, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(chkAccept)
                            .addComponent(chkNotAccept))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlRegisterLayout = new javax.swing.GroupLayout(pnlRegister);
        pnlRegister.setLayout(pnlRegisterLayout);
        pnlRegisterLayout.setHorizontalGroup(
            pnlRegisterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlRegisterLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlRegisterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel23, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel21, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlRegisterLayout.setVerticalGroup(
            pnlRegisterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlRegisterLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                .addGap(46, 46, 46))
        );

        jpanelMain.addTab("Manage Register", pnlRegister);

        jPanel5.setLayout(new java.awt.BorderLayout());

        jPanel6.setLayout(new java.awt.BorderLayout());

        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/background1.jpg"))); // NOI18N
        jPanel6.add(jLabel18, java.awt.BorderLayout.CENTER);

        jPanel5.add(jPanel6, java.awt.BorderLayout.CENTER);

        jpanelMain.addTab("Introduce", jPanel5);

        pnlCustomer.setEnabled(false);

        jLabel16.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel16.setForeground(new java.awt.Color(44, 44, 44));
        jLabel16.setText("Search:");

        txtSearch.setMinimumSize(new java.awt.Dimension(6, 22));

        cbbChoice.setFont(new java.awt.Font("Arial", 1, 12));
        cbbChoice.setForeground(new java.awt.Color(44, 44, 44));
        cbbChoice.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Account No", "Loan Amount", "Period", " " }));

        btnOk.setFont(new java.awt.Font("Arial", 1, 12));
        btnOk.setForeground(new java.awt.Color(44, 44, 44));
        btnOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/search-16x16.png"))); // NOI18N
        btnOk.setText("Ok");
        btnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkActionPerformed(evt);
            }
        });

        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Customer List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        tblCustomer.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblCustomer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblCustomerMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tblCustomer);

        btnCustomerReport.setFont(new java.awt.Font("Arial", 1, 12));
        btnCustomerReport.setForeground(new java.awt.Color(44, 44, 44));
        btnCustomerReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/check-user-16x16.png"))); // NOI18N
        btnCustomerReport.setText("Customer Report");
        btnCustomerReport.setEnabled(false);
        btnCustomerReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCustomerReportActionPerformed(evt);
            }
        });

        btnDeleteDuration.setFont(new java.awt.Font("Arial", 1, 12));
        btnDeleteDuration.setForeground(new java.awt.Color(44, 44, 44));
        btnDeleteDuration.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/delete-16x16.png"))); // NOI18N
        btnDeleteDuration.setText("Delete Duration");
        btnDeleteDuration.setEnabled(false);
        btnDeleteDuration.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteDurationActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE)
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addComponent(btnCustomerReport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnDeleteDuration)))
                .addContainerGap())
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCustomerReport)
                    .addComponent(btnDeleteDuration))
                .addGap(27, 27, 27))
        );

        jPanel19.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Customer Detail", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        jLabel17.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel17.setForeground(new java.awt.Color(44, 44, 44));
        jLabel17.setText("User name:");

        jLabel19.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel19.setForeground(new java.awt.Color(44, 44, 44));
        jLabel19.setText("Address:");

        jLabel20.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel20.setForeground(new java.awt.Color(44, 44, 44));
        jLabel20.setText("Birthday:");

        jLabel21.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel21.setForeground(new java.awt.Color(44, 44, 44));
        jLabel21.setText("Phone:");

        jLabel22.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel22.setForeground(new java.awt.Color(44, 44, 44));
        jLabel22.setText("Email:");

        jLabel23.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel23.setForeground(new java.awt.Color(44, 44, 44));
        jLabel23.setText("Organization:");

        jLabel24.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel24.setForeground(new java.awt.Color(44, 44, 44));
        jLabel24.setText("Salary:");

        lblCusAddress.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusAddress.setForeground(new java.awt.Color(76, 76, 76));
        lblCusAddress.setPreferredSize(new java.awt.Dimension(48, 16));

        lblCusName.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusName.setForeground(new java.awt.Color(76, 76, 76));
        lblCusName.setPreferredSize(new java.awt.Dimension(48, 16));

        lblCusBirthday.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusBirthday.setForeground(new java.awt.Color(76, 76, 76));
        lblCusBirthday.setPreferredSize(new java.awt.Dimension(48, 16));

        lblCusPhone.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusPhone.setForeground(new java.awt.Color(76, 76, 76));
        lblCusPhone.setPreferredSize(new java.awt.Dimension(48, 16));

        lblCusEmail.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusEmail.setForeground(new java.awt.Color(76, 76, 76));
        lblCusEmail.setPreferredSize(new java.awt.Dimension(48, 18));

        lblCusOrg.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusOrg.setForeground(new java.awt.Color(76, 76, 76));
        lblCusOrg.setPreferredSize(new java.awt.Dimension(48, 16));

        lblCusSalary.setFont(new java.awt.Font("Arial", 1, 12));
        lblCusSalary.setForeground(new java.awt.Color(76, 76, 76));
        lblCusSalary.setPreferredSize(new java.awt.Dimension(48, 16));

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel24)
                            .addComponent(jLabel17)
                            .addComponent(jLabel19)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22))
                        .addGap(20, 20, 20))
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblCusOrg, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCusBirthday, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCusPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCusSalary, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCusName, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCusAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCusEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(95, Short.MAX_VALUE))
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel19)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel20))
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addComponent(lblCusName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblCusAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lblCusBirthday, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(16, 16, 16)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel22))
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addComponent(lblCusPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblCusEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblCusOrg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel24)
                    .addComponent(lblCusSalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(54, Short.MAX_VALUE))
        );

        jPanel20.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Customer Durations", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N
        jPanel20.setLayout(new java.awt.BorderLayout());

        tblCusDuration.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblCusDuration.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblCusDurationMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(tblCusDuration);

        jPanel20.add(jScrollPane5, java.awt.BorderLayout.CENTER);

        btnCusDurationDetails.setFont(new java.awt.Font("Arial", 1, 12));
        btnCusDurationDetails.setForeground(new java.awt.Color(44, 44, 44));
        btnCusDurationDetails.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Windows-View-Detail-16x16.png"))); // NOI18N
        btnCusDurationDetails.setText("Duration Details");
        btnCusDurationDetails.setEnabled(false);
        btnCusDurationDetails.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCusDurationDetailsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlCustomerLayout = new javax.swing.GroupLayout(pnlCustomer);
        pnlCustomer.setLayout(pnlCustomerLayout);
        pnlCustomerLayout.setHorizontalGroup(
            pnlCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCustomerLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(pnlCustomerLayout.createSequentialGroup()
                .addGap(117, 117, 117)
                .addComponent(jLabel16)
                .addGap(18, 18, 18)
                .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbbChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnOk)
                .addContainerGap(239, Short.MAX_VALUE))
            .addGroup(pnlCustomerLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, 782, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlCustomerLayout.createSequentialGroup()
                .addContainerGap(638, Short.MAX_VALUE)
                .addComponent(btnCusDurationDetails)
                .addGap(21, 21, 21))
        );
        pnlCustomerLayout.setVerticalGroup(
            pnlCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCustomerLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(pnlCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnOk))
                .addGap(18, 18, 18)
                .addGroup(pnlCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCusDurationDetails)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jpanelMain.addTab("Manage Customer", pnlCustomer);

        pnlDuration.setEnabled(false);

        jPanel24.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List Duration", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        tblListDuration.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblListDuration.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblListDurationMouseClicked(evt);
            }
        });
        jScrollPane8.setViewportView(tblListDuration);

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel24Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel24Layout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel25.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List Duration History", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        tblListDurationHistory.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblListDurationHistory.setToolTipText("");
        tblListDurationHistory.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jScrollPane9.setViewportView(tblListDurationHistory);

        btnFinish.setFont(new java.awt.Font("Arial", 1, 12));
        btnFinish.setForeground(new java.awt.Color(44, 44, 44));
        btnFinish.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/accept-16x16.png"))); // NOI18N
        btnFinish.setText("Finish");
        btnFinish.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinishActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel25Layout = new javax.swing.GroupLayout(jPanel25);
        jPanel25.setLayout(jPanel25Layout);
        jPanel25Layout.setHorizontalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel25Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE)
                    .addComponent(btnFinish, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel25Layout.setVerticalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel25Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnFinish)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlDurationLayout = new javax.swing.GroupLayout(pnlDuration);
        pnlDuration.setLayout(pnlDurationLayout);
        pnlDurationLayout.setHorizontalGroup(
            pnlDurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDurationLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel24, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel25, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlDurationLayout.setVerticalGroup(
            pnlDurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDurationLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jPanel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(98, Short.MAX_VALUE))
        );

        jpanelMain.addTab("Manage Duration", pnlDuration);

        pnlLoanType.setEnabled(false);

        jPanel15.setPreferredSize(new java.awt.Dimension(765, 64));

        jLabel12.setFont(new java.awt.Font("Arial", 1, 24));
        jLabel12.setForeground(new java.awt.Color(102, 102, 255));
        jLabel12.setText("Manage Loan Types");
        jPanel15.add(jLabel12);

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Loan Type Detail", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N

        jLabel13.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel13.setForeground(new java.awt.Color(44, 44, 44));
        jLabel13.setText("Name:");

        jLabel14.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel14.setForeground(new java.awt.Color(44, 44, 44));
        jLabel14.setText("Description:");

        jLabel15.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel15.setForeground(new java.awt.Color(44, 44, 44));
        jLabel15.setText("Rate:");

        txtLoanTypes.setPreferredSize(new java.awt.Dimension(6, 22));

        txtDescription.setPreferredSize(new java.awt.Dimension(6, 22));

        txtRate.setPreferredSize(new java.awt.Dimension(6, 22));
        txtRate.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtRateKeyTyped(evt);
            }
        });

        btnNewLoanType.setFont(new java.awt.Font("Arial", 1, 12));
        btnNewLoanType.setForeground(new java.awt.Color(44, 44, 44));
        btnNewLoanType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/add-16x16.png"))); // NOI18N
        btnNewLoanType.setText("New");
        btnNewLoanType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewLoanTypeActionPerformed(evt);
            }
        });

        btnEditLoanType.setFont(new java.awt.Font("Arial", 1, 12));
        btnEditLoanType.setForeground(new java.awt.Color(44, 44, 44));
        btnEditLoanType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Edit-16x16.png"))); // NOI18N
        btnEditLoanType.setText("Edit");
        btnEditLoanType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditLoanTypeActionPerformed(evt);
            }
        });

        btnSaveLoanType.setFont(new java.awt.Font("Arial", 1, 12));
        btnSaveLoanType.setForeground(new java.awt.Color(44, 44, 44));
        btnSaveLoanType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/save-16x16.png"))); // NOI18N
        btnSaveLoanType.setText("Save");
        btnSaveLoanType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveLoanTypeActionPerformed(evt);
            }
        });

        btnDeleteLoanType.setFont(new java.awt.Font("Arial", 1, 12));
        btnDeleteLoanType.setForeground(new java.awt.Color(44, 44, 44));
        btnDeleteLoanType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/delete-16x16.png"))); // NOI18N
        btnDeleteLoanType.setText("Delete");
        btnDeleteLoanType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteLoanTypeActionPerformed(evt);
            }
        });

        chkStatusLoanType.setFont(new java.awt.Font("Arial", 1, 12));
        chkStatusLoanType.setForeground(new java.awt.Color(44, 44, 44));
        chkStatusLoanType.setText("Status");

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel15)
                            .addComponent(jLabel14)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtRate, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtLoanTypes, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chkStatusLoanType)))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnNewLoanType)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEditLoanType)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSaveLoanType)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDeleteLoanType)))
                .addContainerGap(52, Short.MAX_VALUE))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtLoanTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addGap(18, 18, 18)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addGap(18, 18, 18)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addGap(18, 18, 18)
                .addComponent(chkStatusLoanType)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSaveLoanType)
                    .addComponent(btnEditLoanType)
                    .addComponent(btnNewLoanType)
                    .addComponent(btnDeleteLoanType))
                .addContainerGap())
        );

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Loan Type List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(44, 44, 44))); // NOI18N
        jPanel17.setLayout(new java.awt.BorderLayout());

        tblLoanType.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblLoanType.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblLoanTypeMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                tblLoanTypeMouseEntered(evt);
            }
        });
        jScrollPane3.setViewportView(tblLoanType);

        jPanel17.add(jScrollPane3, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout pnlLoanTypeLayout = new javax.swing.GroupLayout(pnlLoanType);
        pnlLoanType.setLayout(pnlLoanTypeLayout);
        pnlLoanTypeLayout.setHorizontalGroup(
            pnlLoanTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel15, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE)
            .addGroup(pnlLoanTypeLayout.createSequentialGroup()
                .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, 351, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlLoanTypeLayout.setVerticalGroup(
            pnlLoanTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlLoanTypeLayout.createSequentialGroup()
                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlLoanTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel17, 0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jpanelMain.addTab("Manage Loan Type", pnlLoanType);

        jMenuBar1.setFont(new java.awt.Font("Segoe UI", 0, 14));

        jMenu1.setText("File");
        jMenu1.setFont(new java.awt.Font("Segoe UI", 0, 14));

        mnLoanRegister.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/cash-register-16x16.png"))); // NOI18N
        mnLoanRegister.setText("LoanRegister");
        mnLoanRegister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnLoanRegisterActionPerformed(evt);
            }
        });
        jMenu1.add(mnLoanRegister);

        jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/exit-16x16.png"))); // NOI18N
        jMenuItem3.setText("Exit");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        mnEditProfile.setText("Edit");
        mnEditProfile.setFont(new java.awt.Font("Segoe UI", 0, 14));

        mnEditManager.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/check-user-16x16.png"))); // NOI18N
        mnEditManager.setText("ManagerProfile");
        mnEditManager.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnEditManagerActionPerformed(evt);
            }
        });
        mnEditProfile.add(mnEditManager);

        jMenuBar1.add(mnEditProfile);

        jMenu4.setText("Help");
        jMenu4.setFont(new java.awt.Font("Segoe UI", 0, 14));

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/images.png"))); // NOI18N
        jMenuItem1.setText("About Us");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem1);

        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpanelMain, javax.swing.GroupLayout.DEFAULT_SIZE, 807, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpanelMain, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void tblLoanTypeMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblLoanTypeMouseEntered
// TODO add your handling code here:
}//GEN-LAST:event_tblLoanTypeMouseEntered

private void tblLoanTypeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblLoanTypeMouseClicked
// TODO add your handling code here:
    int index = tblLoanType.getSelectedRow();
    if (index != -1) {
        LoanType lt = modelLoanType.getLoanType(index);
        txtLoanTypes.setText(lt.getName());
        txtDescription.setText(lt.getDescription());
        txtRate.setText(String.valueOf(lt.getInterestRate()));
        chkStatusLoanType.setSelected(lt.isStatus());
        tempLoanType = lt.getLoanTypeCode();
    }
}//GEN-LAST:event_tblLoanTypeMouseClicked

private void btnDeleteLoanTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteLoanTypeActionPerformed
// TODO add your handling code here:
    if (tempLoanType != -1) {
        for (int i = 0; i < modelLoanType.getSize(); i++) {
            if (modelLoanType.getLoanType(i).getLoanTypeCode() == tempLoanType) {
                int check = JOptionPane.showConfirmDialog(this, "Do you want to delete?", "Delete", JOptionPane.YES_NO_OPTION);
                if (check == JOptionPane.YES_OPTION) {
                    deleteLoanType(modelLoanType.getLoanType(i));
                    break;
                }
            }
        }
    }
}//GEN-LAST:event_btnDeleteLoanTypeActionPerformed
    private String name;
    private String description;
    private float interestRate;

    /**
     * Addition loan type
     * @param evt 
     */
private void btnSaveLoanTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveLoanTypeActionPerformed
// TODO add your handling code here:
    boolean status = chkStatusLoanType.isSelected();
    name = txtLoanTypes.getText();
    if (dbLoanType.checkLoanType(name)) {
        JOptionPane.showConfirmDialog(this, "Name existed.Please choice another name.", "Error", JOptionPane.ERROR_MESSAGE);
        txtName.requestFocus();
        return;
    } else if (checkValidLoanType()) {
        LoanType lt = new LoanType(name, description, interestRate, status);
        JOptionPane.showMessageDialog(this, "Loan type has been added successful.");
        addLoanType(lt);
    }


}//GEN-LAST:event_btnSaveLoanTypeActionPerformed

private void btnEditLoanTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditLoanTypeActionPerformed
// TODO add your handling code here:
    if (tempLoanType != -1) {
        boolean status = chkStatusLoanType.isSelected();
        if (checkValidLoanType()) {
            LoanType lt = new LoanType(tempLoanType, name, description, interestRate, status);
            updateLoanType(lt);
        }

    }
}//GEN-LAST:event_btnEditLoanTypeActionPerformed

private void btnNewLoanTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewLoanTypeActionPerformed
// TODO add your handling code here:
    txtLoanTypes.setText("");
    txtDescription.setText("");
    txtRate.setText("");
    btnSaveLoanType.setEnabled(true);
}//GEN-LAST:event_btnNewLoanTypeActionPerformed

private void btnFinishActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinishActionPerformed
// TODO add your handling code here:
    //java.sql.Date currentDate = new java.sql.Date(new Date().getTime());
    Calendar calendar = Calendar.getInstance();
    Date currentDate = calendar.getTime();
    Date dateDue = null;
    float amountDue = 0;
    float fineAmount = 0;
    int fineCode = 1;
    int index = tblListDurationHistory.getSelectedRow();
    if (index != -1) {
        DurationDetails durde = modelDurationDetails.getDurationDetails(index);
        boolean status = durde.isStatus();
        dateDue = durde.getDateDue();
        if (currentDate.getYear() < dateDue.getYear()) {
            if (status == false) {
                DurationDetails durde2 = new DurationDetails(durde.getAccountLoanCode(), durde.getFineCode(), dateDue, 0, durde.getAmountDue(), currentDate, true);
                //updateDurationHistory(durde);
            }

        } else if (currentDate.getYear() == dateDue.getYear() && currentDate.getMonth() < dateDue.getMonth()) {
            if (status == false) {
                DurationDetails durde3 = new DurationDetails(durde.getAccountLoanCode(), durde.getFineCode(), dateDue, 0, durde.getAmountDue(), currentDate, true);
                updateDurationHistory(durde3);
            } else {
                JOptionPane.showMessageDialog(this, "You can't edit this duration because of finished");
            }
        } else {
            amountDue = durde.getAmountDue();
            if (0 < amountDue && amountDue <= 5000) {
                fineAmount = amountDue + amountDue * 2 / 100;
                fineCode = 2;
            } else if (amountDue > 5000 && amountDue <= 20000) {
                fineAmount = amountDue + amountDue * 5 / 100;
                fineCode = 3;
            } else if (amountDue > 20000) {
                fineAmount = amountDue + amountDue * 8 / 100;
                fineCode = 4;
            }
            if (status == false) {
                int check = JOptionPane.showConfirmDialog(this, "This month has fine.Must be paid: " + fineAmount + " instead of " + amountDue, "Finish?", JOptionPane.YES_NO_OPTION);
                if (check == JOptionPane.NO_OPTION) {
                    return;
                }
                if (check == JOptionPane.YES_OPTION) {
                    DurationDetails durdeFine = new DurationDetails(durde.getAccountLoanCode(), fineCode, dateDue, 0, durde.getAmountDue(), currentDate, true);
                    updateDurationHistory(durdeFine);
                }
            } else {
                JOptionPane.showMessageDialog(this, "You can't edit this duration because of finished");
            }

        }
    }
}//GEN-LAST:event_btnFinishActionPerformed

private void tblListDurationMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblListDurationMouseClicked
// TODO add your handling code here:

    int index = tblListDuration.getSelectedRow();
    Duration dur = modelDuration.getDuration(index);
    int accountLoanCode = dur.getAccountLoanCode();
    if (flag != accountLoanCode) {
        modelDurationDetails.getDurationDetailsList(dbDurationDetails.getDurationDetailsList(accountLoanCode));
        flag = accountLoanCode;
    }
    ArrayList<DurationDetails> list = new ArrayList<DurationDetails>();
    for (int i = 0; i < modelDurationDetails.getSize(); i++) {
        if (modelDurationDetails.getDurationDetails(i).getAccountLoanCode() - accountLoanCode != 0) {
            list.add(modelDurationDetails.getDurationDetails(i));
        }
    }
    modelDurationDetails.removeDurationHistory(list);
    tblListDurationHistory.setModel(modelDurationDetails);
    RowSorter rs = new TableRowSorter(modelDurationDetails);
    tblListDurationHistory.setRowSorter(rs);
    TableColumnModel tcm = tblListDurationHistory.getColumnModel();
    TableColumn tc = tcm.getColumn(modelDurationDetails.findColumn("Finished"));
    tc.setCellRenderer(new TestRenderer());
}//GEN-LAST:event_tblListDurationMouseClicked

private void btnCusDurationDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCusDurationDetailsActionPerformed
// TODO add your handling code here:
    int index = tblCustomer.getSelectedRow();
    Duration dur = null;
    Account acc = modelCustomerDurations.getAcc(index);
    int registerNo = acc.getResgisterNo();
    AccountDetails accde = null;
    for (int i = 0; i < modelAccountDetails.getSize(); i++) {
        if (modelAccountDetails.getAccountDetails(i).getRegisterNo() == registerNo) {
            accde = modelAccountDetails.getAccountDetails(i);
        }
    }
    int accountLoanCode = accde.getAccountLoanCode();
    for (int i = 0; i < modelDuration.getSize(); i++) {
        if (modelDuration.getDuration(i).getAccountLoanCode() == accountLoanCode) {
            dur = modelDuration.getDuration(i);
        }

    }
    DialogDurationDetails dialogDurationDetails = new DialogDurationDetails(this, false, dur, manager);
    dialogDurationDetails.setLocationRelativeTo(null);
    dialogDurationDetails.setVisible(true);
}//GEN-LAST:event_btnCusDurationDetailsActionPerformed

private void tblCusDurationMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblCusDurationMouseClicked
// TODO add your handling code here:
    btnCusDurationDetails.setEnabled(true);
}//GEN-LAST:event_tblCusDurationMouseClicked

private void btnCustomerReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerReportActionPerformed
// TODO add your handling code here:
    int index = tblCustomer.getSelectedRow();
    if (index != -1) {
        Account account = modelAccount.getAccount(index);
        DialogCustomerReport dialog = new DialogCustomerReport(this, false, account, manager);
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
    }
}//GEN-LAST:event_btnCustomerReportActionPerformed

private void tblCustomerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblCustomerMouseClicked
// TODO add your handling code here:
    int index = tblCustomer.getSelectedRow();
    if (index != -1) {
        Account acc = modelAccount.getAccount(index);
        lblCusAddress.setText(acc.getAddress());
        SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
        String birthday = dateFormat.format(acc.getRegisterDate());
        lblCusBirthday.setText(birthday);
        lblCusEmail.setText(acc.getEmail());
        lblCusName.setText(acc.getName());
        lblCusOrg.setText(acc.getOrganization());
        lblCusPhone.setText(acc.getPhone());
        lblCusSalary.setText(String.valueOf(acc.getSalary()));
        btnCustomerReport.setEnabled(true);
        btnDeleteDuration.setEnabled(true);

        modelCustomerDurations = new CustomerDurationsTableModel(manager);
        modelCustomerDurations.addAcc(acc);
        tblCusDuration.setModel(modelCustomerDurations);
        TableColumnModel tcm = tblCusDuration.getColumnModel();
        TableColumn tc = tcm.getColumn(modelCustomerDurations.findColumn("Loan Status"));
        tc.setCellRenderer(new TestRenderer());
    }
}//GEN-LAST:event_tblCustomerMouseClicked

private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
// TODO add your handling code here:
    if (tempBranchCode != -1) {
        int check = JOptionPane.showConfirmDialog(this, "Do you want delete?", "Delete", JOptionPane.YES_NO_OPTION);
        if (check == JOptionPane.YES_OPTION) {
            for (int i = 0; i < modelBranch.getSize(); i++) {
                if (modelBranch.getBranch(i).getBranchCode() == tempBranchCode) {
                    deleteBranch(modelBranch.getBranch(i));
                    break;
                }
            }
        }
    }
}//GEN-LAST:event_btnRemoveActionPerformed
    /**
     * Process Insert branch
     * @param evt 
     */
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
// TODO add your handling code here:
    String name = txtName.getText().trim();
    String address = txtAddress.getText().trim();
    String phone = txtPhone.getText().trim();
    String email = txtEmail.getText().trim();
    boolean status = chkStatus.isSelected();
    if (name.isEmpty()) {
        JOptionPane.showConfirmDialog(this, "Name can not be blank", "Error", JOptionPane.ERROR_MESSAGE);
        txtName.requestFocus();
    } else if (address.isEmpty()) {
        JOptionPane.showConfirmDialog(this, "Address can not be blank", "Error", JOptionPane.ERROR_MESSAGE);
        txtAddress.requestFocus();
    } else if (!Pattern.matches("0[\\d]{8,11}", phone) || phone.isEmpty()) {
        JOptionPane.showConfirmDialog(this, "Phone must be 8 - 11 digits and start by 0.", "Error", JOptionPane.ERROR_MESSAGE);
        txtPhone.requestFocus();
    } else if (dbBranch.checkEmail(email)) {
        JOptionPane.showConfirmDialog(this, "Email existed.Please choice another email address.", "Error", JOptionPane.ERROR_MESSAGE);
        txtEmail.requestFocus();
    } else if (!Pattern.matches(".+@.+\\.[a-z]+", email)) {
        JOptionPane.showConfirmDialog(this, "Email must be abc@xyz.com", "Error", JOptionPane.ERROR_MESSAGE);
        txtEmail.requestFocus();
    } else {
        Branch br = new Branch(name, address, phone, email, status);
        addBranch(br);
        JOptionPane.showMessageDialog(this, "Branch added successfully.");
    }

}//GEN-LAST:event_btnSaveActionPerformed
    /**
     * Process edit branch
     * @param evt 
     */
private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
// TODO add your handling code here:
    String name = txtName.getText();
    String address = txtAddress.getText();
    String phone = txtPhone.getText();
    String email = txtEmail.getText();
    boolean bl = chkStatus.isSelected();
    if (name.isEmpty()) {
        JOptionPane.showConfirmDialog(this, "Name can not be blank", "Error", JOptionPane.ERROR_MESSAGE);
        txtName.requestFocus();
    } else if (address.isEmpty()) {
        JOptionPane.showConfirmDialog(this, "Address can not be blank", "Error", JOptionPane.ERROR_MESSAGE);
        txtAddress.requestFocus();
    } else if (!Pattern.matches("0[\\d]{8,11}", phone) || phone.isEmpty()) {
        JOptionPane.showConfirmDialog(this, "Phone must be 8 - 11 digits and start by 0.", "Error", JOptionPane.ERROR_MESSAGE);
        txtPhone.requestFocus();
    } else if (!Pattern.matches(".+@.+\\.[a-z]+", email)) {
        JOptionPane.showConfirmDialog(this, "Email must be abc@xyz.com", "Error", JOptionPane.ERROR_MESSAGE);
        txtEmail.requestFocus();
    } else if (tempBranchCode != -1) {
        Branch br = new Branch(tempBranchCode, name, address, phone, email, bl);
        updateBranch(br);
    }
}//GEN-LAST:event_btnEditActionPerformed

private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
// TODO add your handling code here:
    txtName.setText("");
    txtAddress.setText("");
    txtPhone.setText("");
    txtEmail.setText("");
}//GEN-LAST:event_btnNewActionPerformed
    /**
     * Get branch list when mouse clicked
     * @param evt 
     */
private void tblBranchMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBranchMouseClicked
// TODO add your handling code here:
    int index = tblBranch.getSelectedRow();
    if (index != -1) {
        Branch br = modelBranch.getBranch(index);
        txtName.setText(br.getName());
        txtAddress.setText(br.getAddress());
        txtPhone.setText(br.getPhone());
        txtEmail.setText(br.getEmail());
        chkStatus.setSelected(br.isStatus());
        tempBranchCode = br.getBranchCode();
    }
}//GEN-LAST:event_tblBranchMouseClicked

    /**
     * Process delete manager
     * @param evt 
     */
private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
// TODO add your handling code here:
    int index = tblManager.getSelectedRow();
    if (index != -1) {
        Admin ad = modelAdmin.getAdmin(index);
        int check = JOptionPane.showConfirmDialog(this, "Do you want to delete?", "Delete", JOptionPane.YES_NO_OPTION);
        if (check == JOptionPane.YES_OPTION) {
            deleteAdmin(ad);
            lblEmail.setText("");
            lblPermission.setText("");
            lblPhone.setText("");
            lblFullName.setText("");
            lblAccount.setText("");
            lblAddress.setText("");
        }
    }
}//GEN-LAST:event_btnDeleteActionPerformed

private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
// TODO add your handling code here:
    DialogAddAdmin dialog = new DialogAddAdmin(this, false, modelRole);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);
}//GEN-LAST:event_btnAddActionPerformed

    /**
     * Get list manager when mouse clicked
     * @param evt 
     */
private void tblManagerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblManagerMouseClicked
// TODO add your handling code here:
    int index = tblManager.getSelectedRow();
    if (index != -1) {
        Admin ad = modelAdmin.getAdmin(index);
        lblAccount.setText(ad.getAdminAccount());
        lblFullName.setText(ad.getFullName());
        lblEmail.setText(ad.getEmail());
        lblPhone.setText(ad.getPhone());
        int roleCode = ad.getRoleCode();
        Role r = null;
        for (int i = 0; i < modelRole.getSize(); i++) {
            if (modelRole.getRole(i).getRoleCode() == roleCode) {
                r = modelRole.getRole(i);
                break;
            }
        }
        if (r != null) {
            lblPermission.setText(r.getName());
        } else {
            lblPermission.setText("");
        }
        lblAddress.setText(ad.getAddress());
    }
}//GEN-LAST:event_tblManagerMouseClicked
    /**
     * Process search customer
     * @param evt 
     */
    private ArrayList<Account> listAcc2;
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
// TODO add your handling code here:
    int searchCode = 0;
    try {
        searchCode = Integer.parseInt(txtSearch.getText());
    } catch (NumberFormatException ex) {
        modelAccount.getAccountList(listAcc2);
        tblCustomer.setModel(modelAccount);
        txtSearch.requestFocus();
        return;
    }
    int index = cbbChoice.getSelectedIndex();
    switch (index) {
        case 0: {
            int temp = 0;
            ArrayList<Account> al;
            Account acc;
            try {
                al = dbAccount.searchCustomerWithAccount(searchCode);
                acc = al.get(0);
                al.clear();
            } catch (IndexOutOfBoundsException ex) {
                JOptionPane.showMessageDialog(this, "Not found account have got ID: " + searchCode);
                return;
            }
            for (int i = 0; i < listAcc2.size(); i++) {
                if (listAcc2.get(i).getEmail().equalsIgnoreCase(acc.getEmail())) {
                    modelAccount.getAccountList(dbAccount.searchCustomerWithAccount(searchCode));
                    temp = 1;
                }
            }
            if (temp == 0) {
                JOptionPane.showMessageDialog(this, "Account have got id: " + acc.getResgisterNo() + " no depend this loan type");
            }
            break;
        }
        case 1: {
            int temp = 0;
            ArrayList<Account> al;
            int roleCode = 0;
            if (searchCode < 100000 || searchCode > 500000) {
                JOptionPane.showMessageDialog(this, "Loan amount must be < 500000 and > 100000");
                return;
            }
            al = dbAccount.searchCustomerWithLoanAmount(searchCode);
            if (al.isEmpty()) {
                JOptionPane.showMessageDialog(this, "Not found");
                return;
            }
            roleCode = modelAdmin.getAdmin(0).getRoleCode();
            int loanTypeCode = 0;
            for (int i = 0; i < modelRole.getSize(); i++) {
                if (modelRole.getRole(i).getRoleCode() == roleCode) {
                    loanTypeCode = modelRole.getRole(i).getLoanTypeCode();
                }
            }
            ArrayList<Duration> listDur = new ArrayList<Duration>();
            for (int i = 0; i < modelDuration.getSize(); i++) {
                if (modelDuration.getDuration(i).getLoanTypeCode() == loanTypeCode) {
                    listDur.add(modelDuration.getDuration(i));
                }
            }
            ArrayList<AccountDetails> listAccountDetails = new ArrayList<AccountDetails>();
            for (int i = 0; i < modelAccountDetails.getSize(); i++) {
                for (int j = 0; j < listDur.size(); j++) {
                    if (listDur.get(j).getAccountLoanCode() == modelAccountDetails.getAccountDetails(i).getAccountLoanCode()) {
                        listAccountDetails.add(modelAccountDetails.getAccountDetails(i));
                    }
                }
            }
            ArrayList<Account> listAcc3 = new ArrayList<Account>();
            for (int i = 0; i < al.size(); i++) {
                for (int j = 0; j < listAccountDetails.size(); j++) {
                    AccountDetails accountDetails = listAccountDetails.get(j);
                    if (accountDetails.getRegisterNo() == al.get(i).getResgisterNo()) {
                        listAcc3.add(al.get(i));
                        temp = 1;
                    }
                }
            }
            if (temp == 1) {
                modelAccount.getAccountList(listAcc3);
            } else {
                JOptionPane.showMessageDialog(this, "Not Found");
            }

        }
        break;
        case 2: {
            int temp = 0;
            if (searchCode < 0 || searchCode > 5) {
                JOptionPane.showMessageDialog(this, "Period must be < 5 and > 0");
                return;
            }
            ArrayList<Account> listAcc4 = dbAccount.searchCustomerWithPeriod(searchCode);
            if (listAcc4.isEmpty()) {
                JOptionPane.showMessageDialog(this, "Not Found");
                return;
            }
            int roleCode = modelAdmin.getAdmin(0).getRoleCode();
            int loanTypeCode = 0;
            for (int i = 0; i < modelRole.getSize(); i++) {
                if (modelRole.getRole(i).getRoleCode() == roleCode) {
                    loanTypeCode = modelRole.getRole(i).getLoanTypeCode();
                }
            }
            ArrayList<Duration> listDur = new ArrayList<Duration>();
            for (int i = 0; i < modelDuration.getSize(); i++) {
                if (modelDuration.getDuration(i).getLoanTypeCode() == loanTypeCode) {
                    listDur.add(modelDuration.getDuration(i));
                }
            }
            ArrayList<AccountDetails> listAccountDetails = new ArrayList<AccountDetails>();
            for (int i = 0; i < modelAccountDetails.getSize(); i++) {
                for (int j = 0; j < listDur.size(); j++) {
                    if (listDur.get(j).getAccountLoanCode() == modelAccountDetails.getAccountDetails(i).getAccountLoanCode()) {
                        listAccountDetails.add(modelAccountDetails.getAccountDetails(i));
                    }
                }
            }

            ArrayList<Account> listAccount = new ArrayList<Account>();
            for (int i = 0; i < listAccountDetails.size(); i++) {
                for (int j = 0; j < listAcc4.size(); j++) {
                    Account account = listAcc4.get(j);
                    if (listAccountDetails.get(i).getRegisterNo() == account.getResgisterNo()) {
                        listAccount.add(account);
                        temp = 1;
                    }
                }
            }
            if (temp == 1) {
                modelAccount.getAccountList(listAccount);
            } else {
                JOptionPane.showMessageDialog(this, "Not Found");
            }

        }
        break;
        default:
            break;
    }
}//GEN-LAST:event_btnOkActionPerformed

    /**
     * Open Dialog Register customer
     * @param evt 
     */
private void mnLoanRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnLoanRegisterActionPerformed
// TODO add your handling code here:
    DialogRegisterCustomer dialog = new DialogRegisterCustomer(this, false, manager);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);
}//GEN-LAST:event_mnLoanRegisterActionPerformed
    /**
     * Get account register
     * @param evt 
     */
private void tblLoanRegisterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblLoanRegisterMouseClicked
// TODO add your handling code here:
    int index = tblLoanRegister.getSelectedRow();
    if (index != -1) {
        Account acc = modelLoanRegister.getAccount(index);
        SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
        String birthday = dateFormat.format(acc.getRegisterDate());
        String name = acc.getName();
        int id = acc.getResgisterNo();
        String address = acc.getAddress();
        String phone = acc.getPhone();
        String email = acc.getEmail();
        String org = acc.getOrganization();
        lblDOBRegister.setText(birthday);
        lblNameRegister.setText(name);
        lblAddressRegister.setText(address);
        lblEmailRegister.setText(email);
        lblOrgRegister.setText(org);
        lblPhoneRegister.setText(phone);
        lblIdRegister.setText(String.valueOf(id));
        int period = -1;
        int branchCode = -1;
        int accountLoanCode = -1;
        for (int i = 0; i < manager.getAccountDetailsManager().getSize(); i++) {
            if (manager.getAccountDetailsManager().getAccountDetails(i).getRegisterNo() == id) {
                period = manager.getAccountDetailsManager().getAccountDetails(i).getPeriod();
                branchCode = manager.getAccountDetailsManager().getAccountDetails(i).getBranchCode();
                accountLoanCode = manager.getAccountDetailsManager().getAccountDetails(i).getAccountLoanCode();
            }
        }
        String branchName = "";
        for (int i = 0; i < manager.getBranchManager().getSize(); i++) {
            if (manager.getBranchManager().getBranch(i).getBranchCode() == branchCode) {
                branchName = manager.getBranchManager().getBranch(i).getName();
            }
        }
        float loanAmount = 0;
        int typeCode = -1;
        boolean accept = false;
        for (int i = 0; i < manager.getDurationManager().getSize(); i++) {
            if (manager.getDurationManager().getDuration(i).getAccountLoanCode() == accountLoanCode) {
                loanAmount = manager.getDurationManager().getDuration(i).getAmountLoan();
                typeCode = manager.getDurationManager().getDuration(i).getLoanTypeCode();
                accept = manager.getDurationManager().getDuration(i).isAccepted();
            }
        }
        String loanType = "";
        for (int i = 0; i < manager.getLoanTypeManager().getSize(); i++) {
            if (manager.getLoanTypeManager().getLoanType(i).getLoanTypeCode() == typeCode) {
                loanType = manager.getLoanTypeManager().getLoanType(i).getName();
            }
        }
        lblBranchRegister.setText(branchName);
        lblLoanAmountRegister.setText(String.valueOf(loanAmount));
        lblLoanTypeRegister.setText(loanType);
        lblPeriodRegister.setText(String.valueOf(period));
        if (accept) {
            chkAccept.setEnabled(true);
            chkAccept.setSelected(accept);
        } else {
            chkNotAccept.setEnabled(true);
        }



    }
}//GEN-LAST:event_tblLoanRegisterMouseClicked

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
// TODO add your handling code here:
    System.exit(0);
}//GEN-LAST:event_jMenuItem3ActionPerformed

private void mnEditManagerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnEditManagerActionPerformed
// TODO add your handling code here:
    Admin admin = modelAdmin.getAdmin(0);
    DialogManager dialog = new DialogManager(this, false, manager, admin);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);
}//GEN-LAST:event_mnEditManagerActionPerformed

private void txtRateKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRateKeyTyped
// TODO add your handling code here:
    String number = "0123456789";
    if (number.indexOf(evt.getKeyChar()) == -1) {
        evt.consume();
    }
}//GEN-LAST:event_txtRateKeyTyped

private void txtPhoneKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPhoneKeyTyped
// TODO add your handling code here:
    String number = "0123456789";
    if (number.indexOf(evt.getKeyChar()) == -1) {
        evt.consume();
    }
}//GEN-LAST:event_txtPhoneKeyTyped

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
    DialogAboutUs dialog = new DialogAboutUs(this, false);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);
}//GEN-LAST:event_jMenuItem1ActionPerformed

private void btnDeleteDurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteDurationActionPerformed
// TODO add your handling code here:
    int index = tblCustomer.getSelectedRow();
    if (index != -1) {
        Account acc = modelAccount.getAccount(index);
        int registerNo = acc.getResgisterNo();
        int accountLoanCode = -1;
        for (int i = 0; i < modelAccountDetails.getSize(); i++) {
            if (modelAccountDetails.getAccountDetails(i).getRegisterNo() == registerNo) {
                accountLoanCode = modelAccountDetails.getAccountDetails(i).getAccountLoanCode();
            }
        }
        Duration dur = null;
        for (int i = 0; i < modelDuration.getSize(); i++) {
            if (modelDuration.getDuration(i).getAccountLoanCode() == accountLoanCode) {
                dur = modelDuration.getDuration(i);
            }
        }
        DurationDetails durde = null;
        ArrayList<DurationDetails> listDurde = new ArrayList<DurationDetails>();
        for (int i = 0; i < modelDurationDetails.getSize(); i++) {
            if (modelDurationDetails.getDurationDetails(i).getAccountLoanCode() == accountLoanCode) {
                durde = modelDurationDetails.getDurationDetails(i);
                listDurde.add(durde);
            }
        }
        int check = JOptionPane.showConfirmDialog(this, "If you delete this account, duration would delete with them.", "Delete", JOptionPane.YES_NO_OPTION);
        if (check == JOptionPane.YES_OPTION) {
            modelDurationDetails.removeDurationHistory(listDurde);
            boolean test = modelDuration.deleteDuration(dur);
            if (test) {
                modelDuration.fireTableDataChanged();
            }
            modelAccount.removeAccount(index);
            dbAccount.deleteDuration(registerNo);
            JOptionPane.showMessageDialog(this, "This duration deleted.");
        }
    }
}//GEN-LAST:event_btnDeleteDurationActionPerformed
    private int tempBranchCode = -1;
    private int tempLoanType = -1;

    /**
     */
    /**
     * Update DurationHistory
     * @param durde 
     */
    public void updateDurationHistory(DurationDetails durde) {
        modelDurationDetails.updateDurationHistory(durde);
        dbDurationDetails.updateDurationHistory(durde);
    }

    /**
     * Method insert branch
     */
    public void addBranch(Branch br) {
        Branch br2 = dbBranch.insertBranch(br);
        boolean test = modelBranch.addBranch(br2);
        if (test) {
            modelBranch.fireTableDataChanged();
        }
    }

    /**
     * Method update branch
     */
    public void updateBranch(Branch br) {
        dbBranch.updateBranch(br);
        boolean test = modelBranch.updateBranch(br);
        if (test) {
            modelBranch.fireTableDataChanged();
        }
    }

    /**
     * Method delete branch
     * @param index 
     */
    public void deleteBranch(Branch br) {
        dbBranch.deleteBranch(br);
        boolean test = modelBranch.removeBranch(br);
        if (test) {
            modelBranch.fireTableDataChanged();
        }
    }

    /**
     * Method insert loan type
     */
    public void addLoanType(LoanType lt) {
        LoanType lt2 = dbLoanType.addLoanType(lt);
        boolean test = modelLoanType.addLoanType(lt2);
        if (test) {
            modelLoanType.fireTableDataChanged();
        }
    }

    /**
     * Method update Loan Type
     */
    public void updateLoanType(LoanType lt) {
        dbLoanType.updateLoanType(lt);
        boolean test = modelLoanType.updateLoanType(lt);
        if (test) {
            modelLoanType.fireTableDataChanged();
        }
    }

    /**
     * Method delete loan type
     */
    public void deleteLoanType(LoanType lt) {
        dbLoanType.deleteLoanType(lt);
        boolean test = modelLoanType.deleteLoanType(lt);
        if (test) {
            modelLoanType.fireTableDataChanged();
        }
    }

    /**
     * Method addition admin
     * @param ad 
     */
    public void addAdmin(Admin ad) {
        Admin ad2 = dbAdmin.insertAdmin(ad);
        boolean test = modelAdmin.addAdmin(ad2);
        if (test) {
            modelAdmin.fireTableDataChanged();
        }
    }

    private void deleteAdmin(Admin ad) {
        boolean test = modelAdmin.removeAdmin(ad);
        if (test) {
            dbAdmin.deleteAdmin(ad);
            modelAdmin.fireTableDataChanged();
        }


    }

    /**
     * Insert Duration
     * @param dur 
     */
    public Duration addDuration(Duration dur) {
        Duration dur2 = dbDuration.insertDuration(dur);
        boolean test = modelDuration.addDuration(dur2);
        if (test) {
            modelDuration.fireTableDataChanged();
            return dur2;
        }
        return null;
    }

    public void addAccount(Account acc, int accountLoanCode, int period, int branchCode) {
        Account acc2 = dbAccount.addAccount(acc, accountLoanCode, period, branchCode);
        modelAccount.addAccount(acc2);
        modelLoanRegister.addLoanRegister(acc2);
    }

    /**
     * Insert account details
     * @param accde 
     */
    public void addAccountDetails(AccountDetails accde) {
        modelAccountDetails.addAccountDetails(accde);
    }

    /**
     * Insert Duration details
     * @param durde 
     */
    public void addDurationHistory(DurationDetails durde) {
        modelDurationDetails.addDurationHistory(durde);
        dbDurationDetails.insertDurationDetails(durde);
    }

    public void checkLogin(Admin ad) {
        int roleCode = -1;
        if (ad.getRoleCode() != 5) {
            ArrayList<Admin> listAd2 = new ArrayList<Admin>();
            for (int i = 0; i < listAd.size(); i++) {
                if (listAd.get(i).getRoleCode() == ad.getRoleCode() && listAd.get(i).getAdminAccount().equals(ad.getAdminAccount())) {
                    listAd2.add(ad);
                }
            }
            modelAdmin.getAdminList(listAd2);
            tblManager.setModel(modelAdmin);
            for (int i = 0; i < modelAdmin.getSize(); i++) {
                if ((modelAdmin.getAdmin(i).getAdminAccount() == null ? ad.getAdminAccount() == null : modelAdmin.getAdmin(i).getAdminAccount().equals(ad.getAdminAccount()))
                        && (modelAdmin.getAdmin(i).getAdminPass() == null ? ad.getAdminPass() == null : modelAdmin.getAdmin(i).getAdminPass().equals(ad.getAdminPass()))) {
                    roleCode = modelAdmin.getAdmin(i).getRoleCode();
                    break;
                }
            }
        } else {
            modelAdmin.getAdminList(listAd);
            tblManager.setModel(modelAdmin);
            btnAdd.setEnabled(true);
            btnDelete.setEnabled(true);
            jpanelMain.setEnabledAt(5, false);
            jpanelMain.setEnabledAt(2, false);
            mnEditManager.setEnabled(false);
        }
        if (roleCode != -1) {
            if (roleCode != 5) {
                int loanType = -1;
                listRole = dbRole.getRolesList();
                for (int i = 0; i < listRole.size(); i++) {
                    if (listRole.get(i).getRoleCode() == roleCode) {
                        loanType = listRole.get(i).getLoanTypeCode();
                    }
                }
                int accountLoanCode = -1;
                listDuration = dbDuration.getDurationList();
                ArrayList<Duration> listDur2 = new ArrayList<Duration>();
                for (int i = 0; i < listDuration.size(); i++) {
                    if (listDuration.get(i).getLoanTypeCode() == loanType) {
                        accountLoanCode = listDuration.get(i).getAccountLoanCode();
                        listDur2.add(listDuration.get(i));
                    }
                }
                modelDuration.getDurationList(listDur2);
                tblListDuration.setModel(modelDuration);
                int registerNo = -1;
                listAccde = dbAccountDetails.getAccopuntDetailsList();
                ArrayList<AccountDetails> listAccde2 = new ArrayList<AccountDetails>();
                for (int i = 0; i < listAccde.size(); i++) {
                    for (int j = 0; j < listDur2.size(); j++) {
                        Duration duration = listDur2.get(j);
                        if (listAccde.get(i).getAccountLoanCode() == duration.getAccountLoanCode()) {
                            listAccde2.add(listAccde.get(i));
                        }
                    }
                }
                listAcc = dbAccount.getAccountList();
                listAcc2 = new ArrayList<Account>();
                for (int i = 0; i < listAcc.size(); i++) {
                    for (int j = 0; j < listAccde2.size(); j++) {
                        if (listAcc.get(i).getResgisterNo() == listAccde2.get(j).getRegisterNo()) {
                            listAcc2.add(listAcc.get(i));
                        }
                    }
                }
                modelAccount.getAccountList(listAcc2);
                tblCustomer.setModel(modelAccount);
            }
        }

        if (roleCode != -1) {
            switch (roleCode) {
                case 1: {
                    jpanelMain.setEnabledAt(1, false);
                    jpanelMain.setEnabledAt(0, false);
                    jpanelMain.setEnabledAt(6, false);
                    break;
                }
                case 2: {
                    jpanelMain.setEnabledAt(1, false);
                    jpanelMain.setEnabledAt(0, false);
                    jpanelMain.setEnabledAt(6, false);
                    break;
                }
                case 3: {
                    jpanelMain.setEnabledAt(1, false);
                    jpanelMain.setEnabledAt(0, false);
                    jpanelMain.setEnabledAt(6, false);
                    break;
                }
                case 4: {
                    jpanelMain.setEnabledAt(1, false);
                    jpanelMain.setEnabledAt(0, false);
                    jpanelMain.setEnabledAt(6, false);
                    break;
                }
            }
        }
    }

    /**
     * Edit Profile Manage
     * @param ad 
     */
    public void editProfile(Admin ad) {
        dbAdmin.updateProfile(ad);
        modelAdmin.fireTableDataChanged();
    }

    /**
     * Change password
     */
    public void changePassword(Admin ad) {
        dbAdmin.changePassword(ad);
        modelAdmin.fireTableDataChanged();
    }

    /**
     * Test email account
     * @param email
     * @return 
     */
    public boolean checkEmailExist(String email) {
        return dbAccount.checkEmail(email);
    }

    /**
     * Test values of loan type
     * @return 
     */
    public boolean checkValidLoanType() {
        name = txtLoanTypes.getText();
        description = txtDescription.getText();

        if (name.isEmpty()) {
            JOptionPane.showConfirmDialog(this, "Name can not be blank", "Error", JOptionPane.ERROR_MESSAGE);
            txtName.requestFocus();
            return false;
        } else if (description.isEmpty()) {
            JOptionPane.showConfirmDialog(this, "Description can not be blank", "Error", JOptionPane.ERROR_MESSAGE);
            txtDescription.requestFocus();
            return false;
        }
        try {
            interestRate = Float.parseFloat(txtRate.getText());
            if (interestRate <= 0 || interestRate > 100) {
                JOptionPane.showConfirmDialog(this, "Interest rate must be 1-100 percent", "Error", JOptionPane.ERROR_MESSAGE);
                txtRate.requestFocus();
                return false;
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showConfirmDialog(this, "Interest rate must be a number.", "Error", JOptionPane.ERROR_MESSAGE);
            txtRate.requestFocus();
            return false;
        }
        return true;
    }

    /**
     * Test email manage
     * @param email
     * @return 
     */
    public boolean checkEmailAdmin(String email) {
        return dbAdmin.checkEmailAdmin(email);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(SystemManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(SystemManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(SystemManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(SystemManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                SystemManager sm = new SystemManager();
                sm.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnCusDurationDetails;
    private javax.swing.JButton btnCustomerReport;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnDeleteDuration;
    private javax.swing.JButton btnDeleteLoanType;
    private javax.swing.JButton btnEdit;
    private javax.swing.JButton btnEditLoanType;
    private javax.swing.JButton btnFinish;
    private javax.swing.JButton btnNew;
    private javax.swing.JButton btnNewLoanType;
    private javax.swing.JButton btnOk;
    private javax.swing.JButton btnRemove;
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnSaveLoanType;
    private javax.swing.JComboBox cbbChoice;
    private javax.swing.JCheckBox chkAccept;
    private javax.swing.JCheckBox chkNotAccept;
    private javax.swing.JCheckBox chkStatus;
    private javax.swing.JCheckBox chkStatusLoanType;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTabbedPane jpanelMain;
    private javax.swing.JLabel lblAccount;
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblAddressRegister;
    private javax.swing.JLabel lblBranchRegister;
    private javax.swing.JLabel lblCusAddress;
    private javax.swing.JLabel lblCusBirthday;
    private javax.swing.JLabel lblCusEmail;
    private javax.swing.JLabel lblCusName;
    private javax.swing.JLabel lblCusOrg;
    private javax.swing.JLabel lblCusPhone;
    private javax.swing.JLabel lblCusSalary;
    private javax.swing.JLabel lblDOBRegister;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblEmailRegister;
    private javax.swing.JLabel lblFullName;
    private javax.swing.JLabel lblIdRegister;
    private javax.swing.JLabel lblLoanAmountRegister;
    private javax.swing.JLabel lblLoanTypeRegister;
    private javax.swing.JLabel lblNameRegister;
    private javax.swing.JLabel lblOrgRegister;
    private javax.swing.JLabel lblPeriodRegister;
    private javax.swing.JLabel lblPermission;
    private javax.swing.JLabel lblPhone;
    private javax.swing.JLabel lblPhoneRegister;
    private javax.swing.JMenuItem mnEditManager;
    private javax.swing.JMenu mnEditProfile;
    private javax.swing.JMenuItem mnLoanRegister;
    private javax.swing.JPanel pnlBranch;
    private javax.swing.JPanel pnlCustomer;
    private javax.swing.JPanel pnlDuration;
    private javax.swing.JPanel pnlLoanType;
    private javax.swing.JPanel pnlManager;
    private javax.swing.JPanel pnlRegister;
    private javax.swing.JTable tblBranch;
    private javax.swing.JTable tblCusDuration;
    private javax.swing.JTable tblCustomer;
    private javax.swing.JTable tblListDuration;
    private javax.swing.JTable tblListDurationHistory;
    private javax.swing.JTable tblLoanRegister;
    private javax.swing.JTable tblLoanType;
    private javax.swing.JTable tblManager;
    private javax.swing.JTextField txtAddress;
    private javax.swing.JTextField txtDescription;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtLoanTypes;
    private javax.swing.JTextField txtName;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JTextField txtRate;
    private javax.swing.JTextField txtSearch;
    // End of variables declaration//GEN-END:variables
}
